package nl.hanze.monoalphabetic.domain;

/**
 *
 * @author alex
 */
public class CharacterFrequency implements Comparable {

    Character character;
    Double frequency;

    public CharacterFrequency(Character character, Double frequency) {
        this.character = character;
        this.frequency = frequency;
    }      

    public Character getCharacter() {
        return character;
    }

    public void setCharacter(Character character) {
        this.character = character;
    }

    public Double getFrequency() {
        return frequency;
    }

    public String getFormattedFrequency(){
        return String.format("%.3f", frequency);
    }
    
    public void setFrequency(Double frequency) {
        this.frequency = frequency;
    }

    @Override
    public int compareTo(Object o) {
        CharacterFrequency other = (CharacterFrequency) o;

        return this.getFrequency().compareTo(other.getFrequency());
    }

    @Override
    public String toString() {
        return getCharacter().toString() + " " + getFrequency();
    }
}
